#include <DynamicArray.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdbool.h>
#include "Scene.h"
#include "player.h"
#include "monster.h"


<<<<<<< HEAD
/*判断武器的附魔效果*/
int JudgeWeaponEffect(player *p,monster *m)
{
    switch (p->wpn->effect)
    {
    case 1:
        if(GetRand(2) == 1)
            {
                printf("🥶|%s|被你冻结了!当前回合无法操作!",m->name.string);
                sleep(1);
                return Frozen;
            }    
        break;
    case 2:
        if(m->HP < p->wpn->ATK)
        {
            if(p->HP >= p->MAXHP)
                p->HP = p->MAXHP;
            if(p->MAXHP-p->HP < m->HP)
            {
                printf("汲取了|%s|%d❤️\n",m->name.string,p->MAXHP-p->HP);
                sleep(1);
                p->HP = p->MAXHP;
            }  
            else
            {
                printf("汲取了123|%s|%d❤️\n",m->name.string,m->HP);
                p->HP += m->HP;
                sleep(1);
            }      
        }   
        else
        {
            if(p->HP >= p->MAXHP)
                p->HP = p->MAXHP;
            if(p->MAXHP-p->HP < p->wpn->ATK)
            {
                printf("汲取了|%s|%d❤️\n",m->name.string,p->MAXHP-p->HP);
                sleep(1);
                p->HP = p->MAXHP;
            } 
            else
            {
                printf("汲取了|%s|%d❤️\n",m->name.string,p->wpn->ATK);
                sleep(1);
                p->HP += p->wpn->ATK;
            } 
        }
        if(p->HP >= p->MAXHP)
            p->HP = p->MAXHP;
        break;
    case 4:
        if(p->wpn->effect == Combo)
        {
            if(GetRand(2) == 1)
            {
                printf("触法了影击效果,再次攻击|%s|一次,造成了%d伤害\n",m->name.string,p->ATK);
                m->HP -= p->wpn->ATK;
            }
        } 
        break;
    default:
        return -1;
        break;
    }
}

/*判断防具的附魔效果*/
void JudgeDefenceEffect(player *p,monster *m)
{
    switch (p->def->DEF)
    {
    case Reflex:
        int damage = m->ATK / 2 + 1;
        if(damage == 0)
            damage = 1; 
        printf("|%s|受到你盔甲的荆棘效果,受到了%d的伤害!\n",m->name.string,damage);
        m->HP -= damage;
        sleep(1);
        break;
    
    default:
        break;
    }
}



/*判断药剂的附魔效果*/
void JudgeMedicamentEffect(player *p,monster *m)
{
    // medicament *drug;
    // switch (drug->effect)
    // {
    // case Combo:;
        
    //     break;
    
    // default:
    //     break;
    // }
}


bool Battle(player *p,monster *m)
{
    printf("你遭遇到了|%s|  %3d❤️  %2d⚔️   %2d🛡️\n",m->name.string,m->HP,m->ATK,m->DEF);
=======
bool Battle(player *p,monster *m)
{
    printf("你遭遇到了|%s|,  %3d❤️  %2d⚔️\n",m->name.string,m->HP,m->ATK);
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
    //让程序休眠1s
    sleep(1);
    while(1)
    {
        //清屏
        system("clear");
<<<<<<< HEAD
        printf("\n-----------------------战斗状态-------------------------\n");
        printf("敌方信息:💀 名称:|%s| %3d❤️  %2d⚔️   %2d🛡️\n",m->name.string,m->HP,m->ATK,m->DEF);
        PrintPlayer(p);
        printf("\n-----------------------战斗选择-------------------------\n");
        printf("1.进攻(100％)⚔️\n");
        printf("2.暴击(5 0％)💥\n");
        printf("3.逃跑(3 3％)🏳️\n");
        printf("4.使用道具💼\n");
        printf("5.自我了断☠️\n");
        printf("6.嘲讽🤡\n");
        printf("--------------------------------------------------------\n");
=======
        printf("\n--------------------战斗状态----------------------\n");
        PrintPlayer(p);
        printf("敌方信息:💀 名称:|%s| %3d❤️  %2d⚔️\n",m->name.string,m->HP,m->ATK);
        printf("\n--------------------战斗选择----------------------\n");
        printf("1.进攻⚔️\n");
        printf("2.暴击💥\n");
        printf("3.逃跑🏳️\n");
        printf("4.使用道具💼\n");
        printf("--------------------------------------------------\n");
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
        printf("请进行你的选择:");
        int choice = 0;
        while(getchar() != '\n');
        scanf("%d",&choice);
        switch (choice)
        {
            case 1:
<<<<<<< HEAD
                /*玩家进攻*/
                JudgeMedicamentEffect(p,m);
                if(p->ATK <= m->DEF)
                {
                    printf("你无法击碎|%s|的防御,请提升实力再来!\n",m->name.string);
                    sleep(1);
                    printf("|%s|:没吃饭吗?你在挠痒痒嘛😁\n",m->name.string);
                    sleep(1);
                    if(p->wpn != NULL)
                    {
                        p->wpn->count--;
                        if(p->wpn->count == 0)
                        {
                            p->ATK -= p->wpn->ATK;
                            p->wpn = NULL;
                            printf("武器耐久不足!已损坏\n");
                            sleep(1);
                            
                            break;
                        }
                    }
                }
                    
                if(p->ATK > m->DEF)
                {
                    printf("你对|%s|发起了进攻⚔️ ,造成了%d点伤害\n",m->name.string,p->ATK-m->DEF);
                    sleep(1);
                    m->HP = m->HP-p->ATK+m->DEF;
                    if(p->wpn != NULL)
                    {
                        p->wpn->count--;
                        if(p->wpn->count == 0)
                        {
                            p->ATK -= p->wpn->ATK;
                            p->wpn = NULL;
                            printf("武器耐久不足!已损坏\n");
                            sleep(1);
                            
                            break;
                        }
                        
                        int PropEffect = JudgeWeaponEffect(p,m);
                        if(PropEffect == Frozen)
                            break;   
                    }
                    
                }
                /*判断怪物血量是否正常，怪物开始进攻*/ 
=======
                printf("你对|%s|发起了进攻⚔️ ,造成了%d点伤害\n",m->name.string,p->ATK);
                m->HP -= p->ATK;
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
                if(m->HP > 0)
                {
                    if(m->ATK <= p->DEF)
                    {
                        p->HP = p->HP;
<<<<<<< HEAD
                        printf("你的防御值高于|%s|攻击力,|%s|无法对你造成伤害\n",m->name.string,m->name.string);
                        sleep(1);
                        if(p->def != NULL)
                        {
                            p->def->count--;
                            if(IsEqual(&p->def->name,"伤痕累累的神圣之甲") == true)
                            {
                                if(1)
                                {
                                    printf("诶呀|伤痕累累的神圣之甲|突然坏了!\n");
                                    sleep(1);
                                    p->def->count = 0;
                                }
                            }
                            if(p->def->count == 0)
                            {
                                p->DEF -= p->def->DEF;
                                p->def = NULL;
                                printf("盔甲耐久不足!已损坏!\n");
                                sleep(1);
                                break;
                            }
                            JudgeDefenceEffect(p,m);
                        }
=======
                        printf("你的防御值高于|%s|攻击力,|%s|无法对你造成伤害",m->name.string,m->name.string);
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
                    }
                    else
                    {
                        p->HP = p->HP - m->ATK + p->DEF;
                        printf("|%s|对你发起了反击⚔️ ,造成了%d点伤害\n",m->name.string,m->ATK-p->DEF);
<<<<<<< HEAD
                        sleep(1);
                        if(p->def != NULL)
                        {
                            p->def->count--;
                            if(IsEqual(&p->def->name,"伤痕累累的神圣之甲") == true)
                            {
                                if(GetRand(3) == 1)
                                {
                                    printf("诶呀|伤痕累累的神圣之甲|突然坏了!\n");
                                    sleep(1);
                                    p->def->count = 0;
                                }
                            }
                            if(p->def->count == 0)
                            {
                                p->DEF -= p->def->DEF;
                                p->def = NULL;
                                printf("盔甲耐久不足!已损坏!\n");
                                sleep(1);
                                break;
                            }
                            JudgeDefenceEffect(p,m);
                        }
                    }         
                }
                break;

            case 2:
                if(GetRand(2) == 1)
                {
                    if(p->ATK * 2 <= m->DEF)
                    {
                        printf("你无法击碎|%s|的防御,请提升实力再来!\n",m->name.string);
                        sleep(1);
                        printf("|%s|:没吃饭吗?你在挠痒痒嘛😁\n",m->name.string);
                        sleep(1);
                        if(p->wpn != NULL)
                        {
                            p->wpn->count--;
                            if(p->wpn->count == 0)
                            {
                                p->ATK -= p->wpn->ATK;
                                p->wpn = NULL;
                                printf("武器耐久不足!已损坏!\n");
                                sleep(1);
                                break;
                            }
                        }
                    }
                    if(p->ATK * 2 > m->DEF)
                    {
                        printf("你对|%s|发起了暴击💥 ,造成了%d点伤害\n",m->name.string,p->ATK*2 - m->DEF);
                        sleep(1);
                        

                        if(p->wpn != NULL)
                        {
                            p->wpn->count--;
                            if(p->wpn->count == 0)
                            {
                                p->ATK -= p->wpn->ATK;
                                p->wpn = NULL;
                                printf("武器耐久不足!已损坏!\n");
                                sleep(1);
                                break;
                            }
                            int PropEffect = JudgeWeaponEffect(p,m);
                            if(PropEffect == Frozen)
                                break;
                        }   
                        m->HP = m->HP - p->ATK * 2 + m->DEF;
                    }
=======
                    }         
                }
                break;
            case 2:
                if(1)
                //if(GetRand(2) == 1)
                {
                    printf("你对|%s|发起了暴击💥 ,造成了%d点伤害\n",m->name.string,p->ATK*2);
                    m->HP -= 2 * p->ATK;
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
                    if(m->HP > 0)
                    {
                        if(m->ATK <= p->DEF)
                        {
                            p->HP = p->HP;
<<<<<<< HEAD
                            printf("你的防御值高于|%s|攻击力,|%s|无法对你造成伤害\n",m->name.string,m->name.string);
                            sleep(1);
                            if(p->def != NULL)
                            {
                                p->def->count--;
                                if(IsEqual(&p->def->name,"伤痕累累的神圣之甲") == true)
                                {
                                    if(GetRand(3) == 1)
                                    {
                                        printf("诶呀|伤痕累累的神圣之甲|突然坏了!\n");
                                        sleep(1);
                                        p->def->count = 0;
                                    }
                                }
                                if(p->def->count == 0)
                                {
                                    p->DEF -= p->def->DEF;
                                    p->def = NULL;
                                    printf("盔甲耐久不足!已损坏!\n");
                                    sleep(1);
                                    break;
                                }
                                JudgeDefenceEffect(p,m);
                            }
=======
                            printf("你的防御值高于|%s|攻击力,|%s|无法对你造成伤害",m->name.string,m->name.string);
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
                        }
                        else
                        {
                            p->HP = p->HP - m->ATK + p->DEF;
                            printf("|%s|对你发起了反击⚔️ ,造成了%d点伤害\n",m->name.string,m->ATK-p->DEF);
<<<<<<< HEAD
                            sleep(1);
                            if(p->def != NULL)
                            {
                                p->def->count--;
                                if(IsEqual(&p->def->name,"伤痕累累的神圣之甲") == true)
                                {
                                    if(GetRand(3) == 1)
                                    {
                                        printf("诶呀|伤痕累累的神圣之甲|突然坏了!\n");
                                        sleep(1);
                                        p->def->count = 0;
                                    }
                                }
                                if(p->def->count == 0)
                                {
                                    p->DEF -= p->def->DEF;
                                    p->def = NULL;
                                    printf("盔甲耐久不足!已损坏!\n");
                                    sleep(1);
                                    break;
                                }
                                JudgeDefenceEffect(p,m);
                            }
=======
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
                        } 
                    }                   
                }
                else
                {
                    printf("你暴击失败,未造成伤害\n");
<<<<<<< HEAD
                    sleep(1);
                    if(m->ATK <= p->DEF)
                    {
                        p->HP = p->HP;
                        printf("你的防御值高于|%s|攻击力,|%s|无法对你造成伤害\n",m->name.string,m->name.string);
                        sleep(1);
                        if(p->def != NULL)
                        {
                            p->def->count--;
                            if(IsEqual(&p->def->name,"伤痕累累的神圣之甲") == true)
                            {
                                if(GetRand(3) == 1)
                                {
                                    printf("诶呀|伤痕累累的神圣之甲|突然坏了!\n");
                                    sleep(1);
                                    p->def->count = 0;
                                }
                            }
                            if(p->def->count == 0)
                            {
                                p->DEF -= p->def->DEF;
                                p->def = NULL;
                                printf("盔甲耐久不足!已损坏!\n");
                                sleep(1);
                                break;
                            }
                            JudgeDefenceEffect(p,m);
                        }
=======
                    if(m->ATK <= p->DEF)
                    {
                        p->HP = p->HP;
                        printf("你的防御值高于|%s|攻击力,|%s|无法对你造成伤害",m->name.string,m->name.string);
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
                    }
                    else
                    {
                        p->HP = p->HP - m->ATK + p->DEF;
                        printf("|%s|对你发起了反击⚔️ ,造成了%d点伤害\n",m->name.string,m->ATK-p->DEF);
<<<<<<< HEAD
                        sleep(1);
                        if(p->def != NULL)
                        {
                            p->def->count--;
                            if(IsEqual(&p->def->name,"伤痕累累的神圣之甲") == true)
                            {
                                if(GetRand(3) == 1)
                                {
                                    printf("诶呀|伤痕累累的神圣之甲|突然坏了!\n");
                                    sleep(1);
                                    p->def->count = 0;
                                }
                            }
                            if(p->def->count == 0)
                            {
                                p->DEF -= p->def->DEF;
                                p->def = NULL;
                                printf("盔甲耐久不足!已损坏!\n");
                                sleep(1);
                                break;
                            }
                            JudgeDefenceEffect(p,m);
                        }
=======
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
                    } 
                }
                break;
            case 3:
<<<<<<< HEAD
                if(IsEqual(&m->name,"黑 龙") == true)
                {
                    printf("BOSS战,无法逃跑!\n");
                    sleep(1);
                    if(m->ATK <= p->DEF)
                    {
                        p->HP = p->HP;
                        printf("你的防御值高于|%s|攻击力,|%s|无法对你造成伤害\n",m->name.string,m->name.string);
                        sleep(1);
                        if(p->def != NULL)
                        {
                            p->def->count--;
                            if(IsEqual(&p->def->name,"伤痕累累的神圣之甲") == true)
                            {
                                if(GetRand(3) == 1)
                                {
                                    printf("诶呀|伤痕累累的神圣之甲|突然坏了!\n");
                                    sleep(1);
                                    p->def->count = 0;
                                }
                            }
                            if(p->def->count == 0)
                            {
                                p->DEF -= p->def->DEF;
                                p->def = NULL;
                                printf("盔甲耐久不足!已损坏!\n");
                                sleep(1);
                                break;
                            }
                            JudgeDefenceEffect(p,m);
                        }
=======
                if(IsEqual(&m->name,"黑龙🐉") == true)
                {
                    printf("BOSS战,无法逃跑!\n");
                    if(m->ATK <= p->DEF)
                    {
                        p->HP = p->HP;
                        printf("你的防御值高于|%s|攻击力,|%s|无法对你造成伤害",m->name.string,m->name.string);
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
                    }
                    else
                    {
                        p->HP = p->HP - m->ATK + p->DEF;
                        printf("|%s|对你发起了攻击⚔️ ,造成了%d点伤害\n",m->name.string,m->ATK-p->DEF);
<<<<<<< HEAD
                        sleep(1);
                        if(p->def != NULL)
                            {
                            p->def->count--;
                            if(IsEqual(&p->def->name,"伤痕累累的神圣之甲") == true)
                            {
                                if(GetRand(3) == 1)
                                {
                                    printf("诶呀|伤痕累累的神圣之甲|突然坏了!\n");
                                    sleep(1);
                                    p->def->count = 0;
                                }
                            }
                            if(p->def->count == 0)
                            {
                                p->DEF -= p->def->DEF;
                                p->def = NULL;
                                printf("盔甲耐久不足!已损坏!\n");
                                sleep(1);
                                break;
                            }
                            JudgeDefenceEffect(p,m);
                        }
                    } 
                }
                if(GetRand(3) == 1)
                {
                    printf("你成功逃跑了🏳️\n");
                    sleep(1);
=======
                    } 
                }
                if(GetRand(2) == 1)
                {
                    printf("你成功逃跑了🏳️\n");
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
                    return true; //逃离战斗，存活
                }
                else
                {
                    printf("你逃跑失败!");
                    if(m->ATK <= p->DEF)
                    {
                        p->HP = p->HP;
<<<<<<< HEAD
                        printf("你的防御值高于|%s|攻击力,|%s|无法对你造成伤害\n",m->name.string,m->name.string);
                        sleep(1);
                        if(p->def != NULL)
                        {
                            p->def->count--;
                            if(IsEqual(&p->def->name,"伤痕累累的神圣之甲") == true)
                            {
                                if(GetRand(3) == 1)
                                {
                                    printf("诶呀|伤痕累累的神圣之甲|突然坏了!\n");
                                    sleep(1);
                                    p->def->count = 0;
                                }
                            }
                            if(p->def->count == 0)
                            {
                                p->DEF -= p->def->DEF;
                                p->def = NULL;
                                printf("盔甲耐久不足!已损坏!\n");
                                sleep(1);
                                break;
                            }
                            JudgeDefenceEffect(p,m);
                        }
=======
                        printf("你的防御值高于|%s|攻击力,|%s|无法对你造成伤害",m->name.string,m->name.string);
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
                    }
                    else
                    {
                        p->HP = p->HP - m->ATK + p->DEF;
                        printf("|%s|对你发起了攻击⚔️ ,造成了%d点伤害\n",m->name.string,m->ATK-p->DEF);
<<<<<<< HEAD
                        sleep(1);
                        if(p->def != NULL)
                        {
                            p->def->count--;
                            if(IsEqual(&p->def->name,"伤痕累累的神圣之甲") == true)
                            {
                                if(GetRand(3) == 1)
                                {
                                    printf("诶呀|伤痕累累的神圣之甲|突然坏了!\n");
                                    sleep(1);
                                    p->def->count = 0;
                                }
                                
                            }
                            if(p->def->count == 0)
                            {
                                p->DEF -= p->def->DEF;
                                p->def = NULL;
                                printf("盔甲耐久不足!已损坏!\n");
                                sleep(1);
                                break;
                            }
                            JudgeDefenceEffect(p,m);
                        }
=======
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
                    } 
                }
                break;
            case 4:
                ShowBag(p);
<<<<<<< HEAD
                break;
            case 5:
                printf("你想体面一些,选择了自我了断!\n");
                sleep(1);
                p->HP = 0;
                break;
            case 6:
                if(GetRand(5) == 1)
                {
                    printf("你怎么这么逊,我二大爷家的🐕都比你厉害,(▔V▔)凸\n");
                    sleep(1);
                    printf("|%s|: ?????????? (╯▔皿▔)╯\n",m->name.string);
                    sleep(1);
                    printf("|%s|被气的一口老血喷了出来🤧\n",m->name.string);
                    m->HP = 0;
                    break;
                }
                printf("什么也没发生\n");
                if(m->ATK <= p->DEF)
                {
                    p->HP = p->HP;
                    printf("你的防御值高于|%s|攻击力,|%s|无法对你造成伤害\n",m->name.string,m->name.string);
                    sleep(1);
                    if(p->def != NULL)
                    {
                        p->def->count--;
                        if(IsEqual(&p->def->name,"伤痕累累的神圣之甲") == true)
                        {
                            if(GetRand(3) == 1)
                            {
                                printf("诶呀|伤痕累累的神圣之甲|突然坏了!\n");
                                sleep(1);
                                p->def->count = 0;
                            }
                        }
                        if(p->def->count == 0)
                        {
                            p->DEF -= p->def->DEF;
                            p->def = NULL;
                            printf("盔甲耐久不足!已损坏!\n");
                            sleep(1);
                            break;
                        }
                        JudgeDefenceEffect(p,m);
                    }
                }
                else
                {
                    p->HP = p->HP - m->ATK + p->DEF;
                    printf("|%s|对你发起了攻击⚔️ ,造成了%d点伤害\n",m->name.string,m->ATK-p->DEF);
                    sleep(1);
                    if(p->def != NULL)
                        {
                        p->def->count--;
                        if(IsEqual(&p->def->name,"伤痕累累的神圣之甲") == true)
                        {
                            if(GetRand(3) == 1)
                            {
                                printf("诶呀|伤痕累累的神圣之甲|突然坏了!\n");
                                sleep(1);
                                p->def->count = 0;
                            }
                        }
                        if(p->def->count == 0)
                        {
                            p->DEF -= p->def->DEF;
                            p->def = NULL;
                            printf("盔甲耐久不足!已损坏!\n");
                            sleep(1);
                            break;
                        }
                        JudgeDefenceEffect(p,m);
                    }
                } 
                sleep(1);
=======
                sleep(2);
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
                break;
            default:
                break;
        }
        sleep(1);
        if(p->HP <= 0)
        {
            p->HP = 0;
            printf("战斗失败!\n");
<<<<<<< HEAD
            sleep(1);
=======
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
            return false;
        }
        if(m->HP <= 0)
        {
            m->HP = 0;
            printf("|%s|被你击败了!掉落了%d🪙 和 %d exp\n",m->name.string,m->golden,m->exp);
            p->exp += m->exp;
            p->golden += m->golden;
            sleep(1);
            return true;
        }
    }  
}



int main()
{
    //初始化场景
<<<<<<< HEAD
    system("clear");
    // printf("初始化场景中,请稍后...\n");
    // sleep(1);
    // system("clear");
    // printf("初始化场景!20％\n");
    // sleep(1);
    // system("clear");
    // printf("初始化场景!40％\n");
    // sleep(1);
    // system("clear");
    // printf("初始化场景!60％\n");
    // sleep(1);
    // system("clear");
    // printf("初始化场景!80％\n");
    // sleep(1);
    // system("clear");
    // printf("初始化场景!100％\n");
    // sleep(1);
    char *map[MAPSZIE][MAPSZIE] = {0};
=======
    char map[MAPSZIE][MAPSZIE] = {0};
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
    InitMap(map);

    //初始化玩家
    player p;
<<<<<<< HEAD
    // printf("初始化玩家中,请稍后...\n");
    // sleep(1);
    // system("clear");
    // printf("初始化场景!100％\n");
    // printf("初始化玩家!20％\n");
    // sleep(1);
    // system("clear");
    // printf("初始化场景!100％\n");
    // printf("初始化玩家!40％\n");
    // sleep(1);
    // system("clear");
    // printf("初始化场景!100％\n");
    // printf("初始化玩家!60％\n");
    // sleep(1);
    // system("clear");
    // printf("初始化场景!100％\n");
    // printf("初始化玩家!80％\n");
    // sleep(1);
    // system("clear");
    // printf("初始化场景!100％\n");
    // printf("初始化玩家!100％\n");
    // sleep(1);
=======
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
    InitPlayer(&p);
    map[p.x][p.y] = p.symbol;
    

    //初始化怪兽
<<<<<<< HEAD
    // printf("初始化怪物中,请稍后...\n");
    // sleep(1);
    // system("clear");
    // printf("初始化场景!100％\n");
    // printf("初始化玩家!100％\n");
    // printf("初始化怪物!20％\n");
    // sleep(1);
    // system("clear");
    // printf("初始化场景!100％\n");
    // printf("初始化玩家!100％\n");
    // printf("初始化怪物!40％\n");
    // sleep(1);
    // system("clear");
    // printf("初始化场景!100％\n");
    // printf("初始化玩家!100％\n");
    // printf("初始化怪物!60％\n");
    // sleep(1);
    // system("clear");
    // printf("初始化场景!100％\n");
    // printf("初始化玩家!100％\n");
    // printf("初始化怪物!80％\n");
    // sleep(1);
    // system("clear");
    // printf("初始化场景!100％\n");
    // printf("初始化玩家!100％\n");
    // printf("初始化怪物!100％\n");
    // sleep(1);
=======
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
    INITDARRAY(monsters);
    SetMosters(&monsters);
    SetMonsterPosition(&monsters,map);

<<<<<<< HEAD
    // printf("初始化完成!正在进入游戏,请稍后...\n");
    // sleep(2);
    system("clear");
=======
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
    PrintMap(map);
    monster *posM = NULL;
    //移动玩家
    while(1)
    {
        PrintPlayer(&p);
        PlayerMove(&p,map);
<<<<<<< HEAD
        system("clear");
=======
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
        if(posM != NULL)
        {
            map[posM->x][posM->y] = posM->symbol;
            posM = NULL;
        }
        monster *m = GetMonsterByPosition(&monsters,p.x,p.y);
        if(m != NULL)
        {
            if(Battle(&p,m) == false)
            {
<<<<<<< HEAD
                printf("你嘎了!游戏结束!☠️\n");
=======
                printf(" 你嘎了!游戏结束!☠️\n");
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
                sleep(1);
                return -1;
            }

            LevelUp(&p);

            if(m->HP == 0)
            {
<<<<<<< HEAD
                if(IsEqual(&m->name,"黑  龙") == true)
=======
                if(IsEqual(&m->name,"黑龙🐉") == true)
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
                {
                    printf("🎉你击败了BOSS,游戏结束!🎉\n");
                    return 0;
                }
                map[m->x][m->y] = p.symbol;
            }
            else
                posM = m;
        }
        PrintMap(map);
<<<<<<< HEAD
        printf("保存玩家状态:%s\n",PlayerToString(&p).string);
=======
>>>>>>> c412670cb91f5a48c84219f2f6837419b34335e7
    }

    return 0;
}